package com.kaifamiao.uploader.service.impl;

import com.kaifamiao.uploader.dao.FileInfoRepository;
import com.kaifamiao.uploader.entity.FileInfo;
import com.kaifamiao.uploader.service.FileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class FileInfoServiceImpl implements FileInfoService {

    @Autowired
    private FileInfoRepository fileInfoRepository;

    @Override
    public FileInfo checkFile(String identifier) {
        if (!StringUtils.hasText(identifier)){
            throw new IllegalArgumentException("参数错误: identifier 不能为空");
        }
        return fileInfoRepository.findByIdentifier(identifier);
    }

    @Override
    public void save(FileInfo fileInfo) {
        fileInfoRepository.save(fileInfo);
    }
}
